package com.blue.waffle.iwc.domains.helpers;
import java.io.IOException;
import java.io.Reader;

import java.util.ArrayList;
import java.util.List;

import au.com.bytecode.opencsv.CSVReader;

import com.badlogic.gdx.utils.Disposable;

public class CSVHelper implements Disposable{
	
	private Reader file;
	private CSVReader reader;
	
	public CSVHelper(Reader file){
		this.file=file;
	}
	
	public List<String[]> getFileData() throws IOException{
		
		reader = new CSVReader(file);
			
		ArrayList<String[]> fileData=null;
		
		try {
			
			fileData=new ArrayList<String[]>();
			
			String[] line;
			int count=0;
			while (count<5&&(line = reader.readNext())!= null) {
				fileData.add(line);
				count++;
			}
			reader.close();
			reader=null;
		} catch (IOException e) {
			throw e;
		}
		
		return fileData;
	}
	
	public CSVReader getReader() {
		return reader;
	}

	@Override
	public void dispose() {
		this.file=null;
		this.reader=null;
	}

}
